package de.tiw.pr.prototype.util;

import java.util.Properties;

import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;

public class DataStore {
	private static HbDataStore datastore;
	private DataStore(){}
	
	//singleton, just one instance of datastore will be used.
	public static HbDataStore getInstance(){
		if(datastore == null){
			final String dataStoreName = "PurchaseOrderDataStore";
			datastore = HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
			Properties props = new Properties();
			props.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
			props.setProperty("hibernate.connection.url", "jdbc:mysql://localhost/bpel2");
			props.setProperty("hibernate.connection.username", "root");
			props.setProperty("hibernate.connection.password", "");
			props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
			datastore.setProperties(props);
		}
		return datastore;
	}
}
